﻿using System;
using System.Collections.Generic;
using System.Linq.Dynamic;
using System.Linq;
using System.Web.Mvc;
using KPIS.GERP.Models.Class;
using KPIS.GERP.Models.ICM;
using KPIS.GERP.Models.Resources;

namespace KPIS.GERP.Models.Class
{
	public static class LookupUtility
	{
		public static string GetLookupNameFromSelectList(IEnumerable<SelectListItem> selectList, object lookupId)
		{
			foreach (SelectListItem s in selectList)
			{
				if (CompareUtility.IsObjectToStringEqual(lookupId, s.Value))
					return s.Text;
			}
			return string.Empty;
		}

        public static string GetLookupNameFromAllLookup(IcmMasLookUpType.LookUpType pLookUpType)
        {

            Type type = typeof(IcmLookUpTypeCaption); // MyClass is static class with static properties
            foreach (var p in type.GetProperties())
            {
                if(p.Name == pLookUpType.ToString())
                return p.GetValue(null, null) as string; // static classes cannot be instanced, so use null...
            }
            return pLookUpType.ToString();
        }
	}
}
